package com.wang.JinDong2;

import java.util.Scanner;

public class Program {
        static Scanner input = new Scanner(System.in);
        static User user = new User();
        static Seller seller = new Seller();
    public static void begin(){
        while (true){
        System.out.println("*****欢迎来到龙宝商城*****\n" +
                        "请选择您的身份：\n" +
                        "1:龙宝商城买家客户\n2:龙宝商城卖家客户\n3:尊贵VIP\n" +
                "\t\t\t 4:退出\n" +
                "**--**--**--**--**--**--**");

        int choice = input.nextInt();
        switch (choice){
            case 1:
                System.out.println("* * * *请尊贵的买家登录* * * *");
                if(user.logIn()){
                    boolean userFlag =true;
                    System.out.println("登录成功");
                    Pause.pause();
                    while (userFlag){
                    UserProgram.show();
                    int userChoice = input.nextInt();
                    switch (userChoice){
                        case 1:
                            Store.showAll();
                            Pause.pause();
                            break;
                        case 2:
                            System.out.println("请输入你要查询的商品编号");
                            int id = input.nextInt();
                            Store.titleFrame();
                            Store.check(id);
                            break;
                        case 3:
                            user.addShopCar();
                            break;
                        case 4:
                            user.checkShopCar();
                            Pause.pause();
                            break;
                        case 5:
                            user.deleteShopCar();
                            break;
                        case 6:
                            user.buyShopCar();
                            break;
                        case 7:
                            User.checkHistoryBuy();
                            break;
                        default:
                            userFlag=false;
                            System.out.println("退出成功");
                            Pause.pause();
                            break;
                    }
                    }
                }else {
                    System.out.println("登录失败，请重新登录");
                    Pause.pause();
                }

                break;
            case 2:
                     System.out.println("* * * *请尊贵的卖家登录* * * * ");
                     if(seller.logIn()){
                         boolean sellerFlag =true;
                         System.out.println("登录成功");
                         Pause.pause();
                         while (sellerFlag){
                             SellerProgram.show();
                             int userChoice = input.nextInt();
                             switch (userChoice){
                                 case 1:
                                     Store.showAll();
                                     Pause.pause();
                                     break;
                                 case 2:
                                     System.out.println("请输入你要查询的商品编号");
                                     int id = input.nextInt();
                                     Store.titleFrame();
                                     Store.check(id);
                                     break;
                                 case 3:
                                     System.out.println("--------");
                                     seller.addProduct();
                                     break;
                                 case 4:
                                     Store.showAll();
                                     if(Store.list.size()==0){
                                         Pause.pause();
                                         break;
                                     }
                                     System.out.println("请输入您想删除的商品编号");
                                     int deleteId = input.nextInt();
                                     seller.deleteProduct(deleteId);
                                     break;
                                 case 5:
                                     int count =5;
                                     while (count>0){
                                     System.out.print("请输入银行密码：");
                                     String profitPassWord = input.next();
                                     if(profitPassWord.equals(seller.profitPassWord)){
                                         Seller.checkProfit();
                                         Pause.pause();
                                         break;
                                     }else {
                                         System.out.println("密码输入错误，剩余次数："+count+"次！");
                                         count--;
                                     }
                                     }
                                     break;
                                 default:
                                     System.out.println("退出成功");
                                     sellerFlag =false;
                                     break;
                             }
                         }
                     }else {
                         System.out.println("登录失败，请重新登录");
                         Pause.pause();
                     }
                    break;
            case 3:
                System.out.println("您还不是尊贵VIP哦！快去充值吧");
                break;
            case 4:
                System.out.println("退出成功，欢迎下次再来");
                return;
            default:
                System.out.println("您输入有误，请重新输入");
                Pause.pause();
                break;
        }

        }
    }
}
